package org.example.platform.beans.factory;

/**
 * 测试简单Bean容器
 */
public class Test {
    /**
     * 实线bean的定义、注入、获取
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        // 初始化BeanFactory
        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

        // 注册bean
        BeanDefinition beanDefinition = new BeanDefinition(UserService.class);
        beanFactory.registerBeanDefinition("userService",beanDefinition);

        // 获取bean
//        UserService userService = (UserService) beanFactory.getBean("userService");
//        userService.queryUser();
        // 第二次获取 bean from Singleton
//        UserService userService1 = (UserService) beanFactory.getBean("userService");
//        userService1.queryUser();
    }
}
